This document demonstrates how to integrate historical redlining data with modern broadband speed data to identify patterns of digital redlining. We’ve implemented advanced vectorization techniques to capture neighborhood-level detail from the broadband speed map.
First, we’ll load both the historical redlining data and the high-resolution digitized broadband data.
# Load redlining data
redlining_data_path <- "../redlining_map_data/mapping-inequality-census-crosswalk-main/MIv3Areas_2020TractCrosswalk.geojson"
redlining_data <- sf::st_read(redlining_data_path, quiet = TRUE)
# We need to ensure the redlining data has a 'grade' column
if (!"grade" %in% colnames(redlining_data) && "holc_grade" %in% colnames(redlining_data)) {
redlining_data$grade <- redlining_data$holc_grade
} else if (!"grade" %in% colnames(redlining_data) && "grade" %in% colnames(redlining_data)) {
# Already has grade column
} else {
# Create a mock grade column for testing
message("Warning: No grade column found. Creating mock data for testing.")
redlining_data$grade <- sample(c("A", "B", "C", "D"), nrow(redlining_data), replace = TRUE)
}
# Load digitized broadband data
broadband_data_path <- "cleveland_broadband_data.geojson"
if(file.exists(broadband_data_path)) {
broadband_data <- sf::st_read(broadband_data_path, quiet = TRUE)
has_broadband_data <- TRUE
} else {
has_broadband_data <- FALSE
message("Broadband data not found. Please run the digitization script first.")
}
Now we’ll create an interactive map with toggleable layers for both redlining and the high-resolution broadband speeds.
# Create map with both layers
map <- leaflet() %>%
addProviderTiles("CartoDB.Positron", group = "Base Map") %>%
setView(lng = -81.7, lat = 41.5, zoom = 11)
# Add redlining layer
redlining_colors <- c("A" = "#76a865", "B" = "#7cb5bd", "C" = "#ffff00", "D" = "#d9838d")
map <- map %>%
addPolygons(
data = redlining_data,
fillColor = ~redlining_colors[grade],
color = "#000000",
weight = 1,
opacity = 1,
fillOpacity = 0.6,
highlightOptions = highlightOptions(color = "white", weight = 2, bringToFront = TRUE),
label = ~paste0("Grade: ", grade, " - ", label),
group = "Historical Redlining (1930s)"
)
# Add high-resolution broadband layer
broadband_colors <- c(
"0-9 Mbps" = "#d73027",
"10-24 Mbps" = "#f46d43",
"25-49 Mbps" = "#fdae61",
"50-100 Mbps" = "#abd9e9",
"100+ Mbps" = "#74add1"
)
map <- map %>%
addPolygons(
data = broadband_data,
fillColor = ~color_code,
color = "#000000",
weight = 1,
opacity = 1,
fillOpacity = 0.7,
highlightOptions = highlightOptions(
color = "white",
weight = 2,
bringToFront = TRUE,
fillOpacity = 0.9
),
label = ~paste0("Broadband Speed: ", speed_category),
popup = ~paste0("<strong>Broadband Speed:</strong> ", speed_category),
group = "Broadband Speeds (2023)"
)
# Add school locations if available
schools_path <- "../schools_geocoded.rds"
if(file.exists(schools_path)) {
schools_data <- readRDS(schools_path)
map <- map %>%
addCircleMarkers(
data = schools_data,
lng = ~longitude,
lat = ~latitude,
radius = 5,
color = "#0000FF",
fillOpacity = 0.8,
label = ~school_name,
group = "Schools"
)
}
# Add layer controls with expanded basemap options
map %>%
addProviderTiles("Esri.WorldImagery", group = "Satellite") %>%
addProviderTiles("OpenStreetMap", group = "OpenStreetMap") %>%
addLayersControl(
baseGroups = c("Base Map", "Satellite", "OpenStreetMap"),
overlayGroups = c("Historical Redlining (1930s)", "Broadband Speeds (2023)", "Schools"),
options = layersControlOptions(collapsed = FALSE)
) %>%
addLegend(
position = "bottomright",
colors = redlining_colors,
labels = names(redlining_colors),
title = "HOLC Grades (1930s)",
opacity = 0.7,
group = "Historical Redlining (1930s)"
) %>%
addLegend(
position = "bottomright",
colors = broadband_colors,
labels = names(broadband_colors),
title = "Broadband Speeds",
opacity = 0.7,
group = "Broadband Speeds (2023)"
) %>%
addScaleBar(position = "bottomleft")